package com.towery.dbsrcmanager.db.utils;

import com.towery.dbsrcmanager.mybatis.base.entity.TDatabaseVO;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import javax.sql.DataSource;

/**
 * Created by User on 2017/1/3.
 */
public class HikariCPDataSourcePool implements DataSourcePoolWrapper {
    @Override
    public DataSource wrap(TDatabaseVO rptDs) {
        HikariConfig config = new HikariConfig();
        config.setMaximumPoolSize(10);
        config.setDriverClassName(rptDs.getJdbcclass());
        config.setJdbcUrl(rptDs.getJdbcurl());
        config.setUsername(rptDs.getDbuser());
        config.setPassword(rptDs.getDbpassword());
        return  new HikariDataSource(config);
    }
}
